Page({
  data: {
    approvalList: [
      {
        id: 1,
        state: '未审核',
        stateColor: 'orange'
      }, {
        id: 2,
        state: '审核通过',
        stateColor: 'green'
      }, {
        id: 3,
        state: '审核不通过',
        stateColor: 'red'
      }
    ],
    index: 0,
    bIsClassRoomBorrow: false, // 教室借用
    bIsClassFreeListen: false, // 课程免听
    bIsClassReplace: false,  // 课程替换
    bIsCollege: false, // 学院审核
    bIsJiaoWu: false, // 教务审核
    userInfo: ''
  },
  onLoad (option) {
    this.setData({
      userInfo: wx.getStorageSync('userInfo')
    })
    const userId = this.data.userInfo.userId
    if (userId === '00000000') {
      this.setData({
        bIsCollege: true
      })
    } else if (userId === '88888888') {
      this.setData({
        bIsJiaoWu: true
      })
    } else {
      this.setData({
        'approvalList[0].state': '学院未审核 → 教务未审核',
        'approvalList[1].state': '学院未审核 → 教务未审核',
        'approvalList[2].state': '学院未审核 → 教务未审核',
        bIsCollege: false,
        bIsJiaoW: false
      })
    }
    const { id } = option
    switch (id) {
      case '0':
        this.setData({
          bIsClassRoomBorrow: true
        })
        break
      case '1':
        this.setData({
          bIsClassFreeListen: true
        })
        break
      case '2':
        this.setData({
          bIsClassReplace: true
        })
        break
      default:
        break
    }
  },
  bindApproval (e) {
    this.setData({
      index: e.detail.value
    })
  },
  bindGoBack (e) {
    wx.navigateBack({
      delta: 1
    })
  }
})